#!/usr/bin/env bash

# use /tmp/crypto-config.yaml to generate /tmp/crypto-config
# use /tmp/org3/crypto-config.yaml to generate /tmp/org3/crypto-config

cd /tmp # we use /tmp as the base working path

# The crypto-config will be used by channel artifacts generation later
CRYPTO_CONFIG=crypto-config

echo "Generating crypto-config..."
cryptogen generate \
  --config=crypto-config.yaml \
  --output ${CRYPTO_CONFIG}

if [ $? -ne 0 ]; then
  echo "Failed to generate crypto-config..."
  exit 1
fi

echo "Generated credential files and saved to ${CRYPTO_CONFIG}."
